package com.imy.virtual.client.hook.proxies.appops;

import android.app.IServiceConnection;

import com.imy.virtual.client.hook.base.MethodProxy;
import com.imy.virtual.client.hook.secondary.ServiceConnectionDelegate;
import com.imy.virtual.client.ipc.VActivityManager;

import java.lang.reflect.Method;

@SuppressWarnings("unused")
class MethodProxies {
    static class checkPackage extends MethodProxy {
        @Override
        public String getMethodName() {
            return "checkPackage";
        }
        @Override
        public Object call(Object who, Method method, Object... args) throws Throwable {
            IServiceConnection conn = (IServiceConnection) args[0];
            ServiceConnectionDelegate delegate = ServiceConnectionDelegate.removeDelegate(conn);
            if (delegate == null) {
                return method.invoke(who, args);
            }
            return VActivityManager.get().unbindService(delegate);
        }
        @Override
        public boolean isEnable() {
            return isAppProcess() || isServerProcess();
        }
    }
}
